Add workaround for QuantumRange not defined error when hdri is disabled #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to: #40
Not sure if this is the optimal solution (excluding the fix in bindgen of course which, of course, is) or whether you think adding this kind of workaround is a good idea but I've done it for my own benefit so maybe others would find it useful.
This defines a feature which the user of the library can enable in their project in the case that they're using a build of ImageMagick with --disable-hdri compiled in.
It just uses the same values defined in magick-type.h for each QuantumDepth to the best of my understanding although this may be worth double checking as part of the review. Tests pass with such an ImageMagick build if you run the tests as
cargo test --features=disable-hdri
.Things to note are: Introduces a
Result
object when accessing theQuantumRange
and I've not attempted to do anything clever with the types as implied in the magick-type.h file casting it to aQuantum
which itself is another type and so on... I've just gone withf64
. I've only gone as far as validating that you can still produce a convincingly sepia toned image (with a value of 0.65) with hdri disabled at Q8 with this change.